package com.lili.operate.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.model.operate.DistributionCash;
import com.lili.model.operate.DistributionOrder;
import com.lili.operate.mapper.DistributionOrderMapper;
import com.lili.operate.service.DistributionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class DistributionOrderServiceImpl implements DistributionOrderService {
    @Autowired
    DistributionOrderMapper distributionOrderMapper;

    @Override
    public Page<DistributionOrder> queryDistributionOrder(Map map) {
        int current = 1;
        int size = 3;
        if(map.get("current") != null)
            current = Integer.parseInt(map.get("current").toString());
        if (map.get("size") != null)
            size = Integer.parseInt(map.get("size").toString());
        Page<DistributionOrder> page = new Page<>(current,size);
        QueryWrapper<DistributionOrder> wrapper = new QueryWrapper<>();
        if (map.get("startTime") != null && map.get("startTime") != null)
            wrapper.between("createTime",map.get("startTime").toString(),map.get("endTime").toString());
        if (map.get("orderSn") != null)
            wrapper.eq("order_sn",map.get("orderSn").toString());
        if (map.get("storeId") != null)
            wrapper.eq("store_id",map.get("storeId").toString());
        if (map.get("distributionName") != null)
            wrapper.eq("distribution_name",map.get("distributionName").toString());
        distributionOrderMapper.selectPage(page,wrapper);
        return page;
    }
}
